package net.hn.hnms.biz.project.enums;

import cn.hutool.core.date.DatePattern;
import cn.hutool.core.util.StrUtil;

import java.util.Arrays;

public enum PlanDateType {
    DAY("0", DatePattern.NORM_DATE_PATTERN,"日计划",DatePattern.PURE_DATE_PATTERN,DatePattern.PURE_DATETIME_PATTERN),
    MONTH("1",DatePattern.NORM_MONTH_PATTERN,"月计划",DatePattern.SIMPLE_MONTH_PATTERN,DatePattern.PURE_DATETIME_PATTERN),
    YEAR("2",DatePattern.NORM_YEAR_PATTERN,"年计划",DatePattern.NORM_YEAR_PATTERN,DatePattern.PURE_DATETIME_PATTERN),
    WEEK("3",DatePattern.NORM_YEAR_PATTERN,"周计划",DatePattern.PURE_DATE_PATTERN,DatePattern.PURE_DATETIME_PATTERN),
    ;

    private String code;

    private String format;

    private String desc;

    private String planNameFormat;

    private String planCodeFormat;

    private static PlanDateType[] values;
    static {
        values = PlanDateType.values();
    }


    PlanDateType(String code, String format, String desc, String planNameFormat, String planCodeFormat) {
        this.code = code;
        this.format = format;
        this.desc = desc;
        this.planNameFormat = planNameFormat;
        this.planCodeFormat = planCodeFormat;
    }

    public String getFormat() {
        return format;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public String getPlanCodeFormat() {
        return planCodeFormat;
    }

    public String getPlanNameFormat() {
        return planNameFormat;
    }

    public static String getFormat(String code) {
        return Arrays.stream(values).filter(o -> StrUtil.equals(code, o.getCode())).findFirst().orElse(PlanDateType.DAY).getFormat();
    }

    public static PlanDateType getByCode(String code) {
        return Arrays.stream(values).filter(o -> StrUtil.equals(code, o.getCode())).findFirst().orElse(PlanDateType.DAY);
    }
}
